package com.ss.android.account.v2.c;

import android.content.Context;
import android.os.Bundle;
import android.os.Looper;
import android.text.TextUtils;

import com.bytedance.common.utility.collection.WeakHandler;
import com.bytedance.frameworks.b.a.ComponentsManifest;
import com.ss.android.account.v2.a.b;
import com.ss.android.account.v2.b.f;
import com.ss.android.article.browser.R;
import com.ss.android.common.util.ToolUtils;

public final class d extends a {
    public b e;
    com.ss.android.account.e.b f;
    boolean g;
    private f h;

    public d(Context arg3) {
        super(arg3);
        this.g = true;
        this.e = ComponentsManifest.findComponent(com.ss.android.account.v2.bb.class).b();
        this.f = new com.ss.android.account.e.b(new com.ss.android.account.e.b.a(this));
    }

    public final void a(Bundle arg3, Bundle arg4) {
        super.a(arg3, arg4);
        int v0 = arg3 == null || !arg3.getBoolean("extra_auto_send_code") ? 0 : 1;
        if (v0 != 0) {
            String v0_1 = arg3.getString("extra_mobile_num");
            if (android.support.design.a.isTelephoneNo(((CharSequence) v0_1))) {
                this.b(v0_1, null);
            }
        }
    }

    public final void a(String arg4) {
        int v0 = -1;
        switch (arg4.hashCode()) {
            case -1530308138: {
                if (!arg4.equals("qzone_sns")) {
                    break;
                }

                v0 = 1;
                break;
            }
            case -1429363305: {
                if (!arg4.equals("telecom")) {
                    break;
                }

                v0 = 7;
                break;
            }
            case -1206476313: {
                if (!arg4.equals("huawei")) {
                    break;
                }

                v0 = 6;
                break;
            }
            case -791575966: {
                if (!arg4.equals("weixin")) {
                    break;
                }

                v0 = 0;
                break;
            }
            case -589445623: {
                if (!arg4.equals("qq_weibo")) {
                    break;
                }

                v0 = 3;
                break;
            }
            case -471473230: {
                if (!arg4.equals("sina_weibo")) {
                    break;
                }

                v0 = 2;
                break;
            }
            case 97536331: {
                if (!arg4.equals("flyme")) {
                    break;
                }

                v0 = 5;
                break;
            }
            case 730878681: {
                if (!arg4.equals("renren_sns")) {
                    break;
                }

                v0 = 4;
                break;
            }
        }

        switch (v0) {
            case 0: {
                this.b("mobile_login_click_weixin");
                break;
            }
            case 1: {
                this.b("mobile_login_click_qq");
                break;
            }
            case 2: {
                this.b("mobile_login_click_sinaweibo");
                break;
            }
            case 3: {
                this.b("mobile_login_click_qqweibo");
                break;
            }
            case 4: {
                this.b("mobile_login_click_renren");
                break;
            }
            case 5: {
                this.b("mobile_login_flyme");
                break;
            }
            case 6: {
                this.b("mobile_login_huawei");
                break;
            }
            case 7: {
                this.b("mobile_login_click_telecom");
                break;
            }
        }

        if (!"weixin".equals(arg4) || (ToolUtils.isAppInstalled(((com.ss.android.account.d.b) this).b, "com.tencent.mm"))) {
            super.a(arg4);
        } else if (this.c()) {
            ((com.ss.android.account.d.d) this.a).a(((com.ss.android.account.d.b) this).b.getString(com.ss.android.article.browser.R.string.toast_weixin_not_install));
        }
    }

    protected final void a(String arg5, int arg6, String arg7, Object arg8) {
        if (arg6 == 1202 || arg6 == 1203) {
            if (this.c()) {
                ((com.ss.android.account.d.d) this.a).c(arg7);
                ((com.ss.android.account.d.d) this.a).e();
            }
        } else if (com.ss.android.account.customview.a.e.a(arg6, arg8)) {
            if (this.c()) {
                ((com.ss.android.account.d.d) this.a).a(((com.ss.android.account.activity.mobile.d.c) arg8).c, arg7, ((com.ss.android.account.activity.mobile.d.c) arg8).e, new g(this, arg5));
            }
        } else if (this.c()) {
            ((com.ss.android.account.d.d) this.a).a(arg7);
            ((com.ss.android.account.d.d) this.a).e();
        }
    }

    final void b(String arg7, String arg8) {
        if (android.support.design.a.isTelephoneNo(((CharSequence) arg7))) {
            if (this.c()) {
                ((com.ss.android.account.d.d) this.a).c();
            }

            this.h = new com.ss.android.account.v2.c.e(this, arg7);
            com.ss.android.account.v2.b.a v0 = this.c;
            int v5 = this.g ? 24 : 25;
            com.ss.android.account.v2.b.b v3 = new com.ss.android.account.v2.b.b(v0, this.h);
            if (!v0.a(v3)) {
                return;
            }

            new com.ss.android.account.activity.mobile.d.h((Context) v0.a.a.get(),
                    new WeakHandler(Looper.getMainLooper(), v3), com.ss.android.account.v2.b.a.a(arg7), arg8, v5).start();
        } else if (this.c()) {
            ((com.ss.android.account.d.d)this.a).f();
        }
    }

    public final void b() {
        super.b();
        this.e();
        this.f.a();
        if (this.c()) {
            ((com.ss.android.account.d.d)this.a).d();
        }
    }

    public final void c(String arg2) {
        this.b(arg2, null);
    }

    public final void c(String arg4, String arg5) {
        int v2 = R.string.account_auth_code_error;
        if (TextUtils.isEmpty(((CharSequence) arg4))) {
            if (this.c()) {
                ((com.ss.android.account.d.d)this.a).f();
            }
        } else if (!android.support.design.a.isTelephoneNo(((CharSequence) arg4))) {
            if (this.c()) {
                ((com.ss.android.account.d.d)this.a).f();
            }
        } else if (TextUtils.isEmpty(((CharSequence) arg5))) {
            if (this.c()) {
                ((com.ss.android.account.d.d)this.a).c(((com.ss.android.account.d.b) this).b.getString(v2));
            }
        } else if (android.support.design.a.b(((CharSequence) arg5))) {
            super.a(arg4, arg5);
        } else if (this.c()) {
            ((com.ss.android.account.d.d)this.a).c(((com.ss.android.account.d.b) this).b.getString(v2));
        }
    }

    public final void e() {
        super.e();
        if (this.h != null) {
            this.h.a = true;
            this.h = null;
        }
    }

    protected final void g() {
        if ((TextUtils.isEmpty(this.d)) || !this.d.equals("article_detail_pgc_like")) {
            android.support.design.a.a(this.b, ((com.ss.android.account.d.b) this).b.getResources().getString(com.ss.android.article.browser.R.string.account_login_success), null, 0);
        }

        this.b("mobile_login_success");
    }

    public final void onAccountRefresh(boolean arg1, int arg2) {
        super.onAccountRefresh(arg1, arg2);
        if (arg1) {
            this.f();
        }
    }
}

